package com.jh.complicate.rpc.v2.client;

import com.jh.complicate.rpc.v1.api.IUserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author Administrator
 * @projectName newforward
 * @title ClientApp.java
 * @package com.jh.complicate.rpc.v1.client
 * @description 客户端远程调度
 * @date 2019/6/12 00:07
 */
public class ClientApp {
    public static void main(String[] args) {
        // 加载Spring配置
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        // spring获取代理客户端
        RPCProxyClient client = context.getBean(RPCProxyClient.class);
        // 动态代理出接口的代理类
        IUserService userService = client.clientProxy(IUserService.class, "localhost", 8080);
        // 通过代理类调用方法
        String result = userService.sayHello("Tom");
        // 输出结果
        System.out.println(result);

    }
}
